#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>
#include <assert.h>

void* my_memcpy(void* dest, void* src, size_t byte)
{
	void* ret = dest;
	while (byte--)
	{
		assert(dest && src);
		*(char*)dest = *(char*)src;
		dest = (char*)dest+1;//or (*(char*)dest)++
	    src = (char*)src+1;
	}  
	return ret;
 } 

int main1()
{
	int arr1[] = { 1,2,3,4,5,6,7,8,9,10 };
	int arr2[10] = { 0 };
	my_memcpy(arr2, arr1, 20);
	for (int i = 0; i < 10; i++)
	{
		printf("%d ", arr2[i]);
	}
	return 0;
}

void* my_memmove(void* dest, void* src, size_t byte)
{
	assert(dest && src);
	void* ret = dest;
		if (dest > src)
		{
			while (byte--)
			{
				*((char*)dest + byte) = *((char*)src + byte);
			}
		}
		else
		{ 
			while (byte--)
			{
				*(char*)dest = *(char*)src;
				dest = (char*)dest + 1;//or (*(char*)dest)++
				src = (char*)src + 1;
			}
		}
		return ret;
}
int main()
{
	int arr1[] = { 1,2,3,4,5,6,7,8,9,10 };
	my_memmove(arr1+2,arr1,20);
	for (int i = 0; i < 10; i++)
	{
		printf("%d ", arr1[i]);
	 }
	return 0;
}